<?php
	
	class Devmod_method_export extends Devmod_methods_abstraction {

		// export does not set sth in the config
		public function set_config($args) {}

		/**
		 * operation for type: list
		 */
		public function operation_list() 
		{
			$q = $this->db->select($this->config['sql_table'], $this->config[$this->type]['original'], isset($this->config[$this->type]['sql']) ? $this->config[$this->type]['sql'] : false, true);
			$q = $this->helper->output_to_array($q);
			return $q;
		}
		
		public function operation_frontend_list() 
		{
			$q = $this->db->select($this->config['sql_table'], $this->config[$this->type]['original'], isset($this->config[$this->type]['sql']) ? $this->config[$this->type]['sql'] : false, true);
			$q = $this->helper->output_to_array($q);
			return $q;
		}
		
		public function operation_edit() 
		{
			$q = $this->db->select($this->config['sql_table'], $this->config[$this->type]['original'], 'WHERE ' . $this->config[$this->type]['where'], false);
			$q = $this->helper->output_to_array($q);
			return $q;
		}
		
		public function operation_add()
		{
			return $this->config[$this->type]['fields'];
		}
		
		public function operation_frontend_add()
		{
			return $this->config[$this->type]['fields'];
		}

		public function finalize_list($args)
		{
			$this->view->assign('grid_view_obj',$this->helper->output_to_array($args));
			
			return $this->view->fetch('common/grid_list.tpl');
		}
		
		public function finalize_frontend_list($args)
		{
			return $this->helper->object_to_array($args); // should be used soon everywhere: OUTPUT ARRAY ONLY!!! TODO: HEERE FIX
		}
		
		public function finalize_edit($args)
		{
			$this->view->assign(array(
				'grid_edit_obj' => $args,
				'host' => SiteConfig::Domain,
				'theme' => "theme/" . Yomm_Config::VAR_BACKEND_THEME . "/"
			));
			return $this->view->fetch('common/grid_edit.tpl');
		}

		public function finalize_add($args)
		{	
			$this->view->assign(array(
				'grid_view_obj' => $args,
				'host' => SiteConfig::Domain,
				'theme' => "theme/" . Yomm_Config::VAR_BACKEND_THEME . "/"
			));
			return $this->view->fetch('common/grid_add.tpl');
		}
		
		public function finalize_frontend_add($args)
		{
			return $args;
		}
		
	}
